<!doctype html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="resources/shadow-dom.js"></script>
</head>
<body>
  <div id="sandbox"></div>
<script>
description("Tests for node's contains().");

document.getElementById('sandbox').appendChild(
   createDOM('div', {'id': 'shadowHostA'},
       createShadowRoot(
           createDOM('div', {'id': 'divA'}),
           createDOM('div', {'id': 'shadowHostB'},
               createShadowRoot(
                   createDOM('div', {'id': 'divB'}))),
           createDOM('div', {'id': 'shadowHostC'},
               createShadowRoot(
                   createDOM('div', {'id': 'divC'}))))));


// Comparing a document with a node in a shadow tree.
shouldBeFalse('document.contains(getNodeInComposedTree("shadowHostA/"))');
shouldBeFalse('getNodeInComposedTree("shadowHostA/").contains(document)');
shouldBeFalse('document.contains(getNodeInComposedTree("shadowHostA/divA"))');
shouldBeFalse('getNodeInComposedTree("shadowHostA/divA").contains(document)');

// Comparing a node in document with a node in a shadow tree.
shouldBeTrue('getNodeInComposedTree("shadowHostA/").contains(getNodeInComposedTree("shadowHostA/divA"))');
shouldBeFalse('getNodeInComposedTree("shadowHostA/divA").contains(getNodeInComposedTree("shadowHostA/"))');

// Comparing a node in a shadow tree with a node in a shadow tree enclosing the first tree.
shouldBeFalse('getNodeInComposedTree("shadowHostA/").contains(getNodeInComposedTree("shadowHostA/shadowHostB/"))');
shouldBeFalse('getNodeInComposedTree("shadowHostA/shadowHostB/").contains(getNodeInComposedTree("shadowHostA/"))');
shouldBeFalse('getNodeInComposedTree("shadowHostA/divA").contains(getNodeInComposedTree("shadowHostA/shadowHostB/divB"))');
shouldBeFalse('getNodeInComposedTree("shadowHostA/shadowHostB/divB").contains(getNodeInComposedTree("shadowHostA/divA"))');

// Comparing a node in a shadow tree with a node in a sibling shadow tree.
shouldBeFalse('getNodeInComposedTree("shadowHostA/shadowHostB/").contains(getNodeInComposedTree("shadowHostA/shadowHostC/"))');
shouldBeFalse('getNodeInComposedTree("shadowHostA/shadowHostC/").contains(getNodeInComposedTree("shadowHostA/shadowHostB/"))');
shouldBeFalse('getNodeInComposedTree("shadowHostA/shadowHostB/divB").contains(getNodeInComposedTree("shadowHostA/shadowHostC/divC"))');
shouldBeFalse('getNodeInComposedTree("shadowHostA/shadowHostC/divC").contains(getNodeInComposedTree("shadowHostA/shadowHostB/divB"))');

// Self-comparing a node in a shadow tree.
shouldBeTrue('getNodeInComposedTree("shadowHostA/shadowHostB").contains(getNodeInComposedTree("shadowHostA/shadowHostB"))');
shouldBeTrue('getNodeInComposedTree("shadowHostA/shadowHostB/").contains(getNodeInComposedTree("shadowHostA/shadowHostB/"))');
</script>
</body>
